package cn.cstech.aijia.model;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;

/**
 * Created with Android Studio.
 * Title:RenovationCaseList
 * Description:
 * Copyright:Copyright (c) 2014
 * Company:中国平安健康保险有限公司
 * Author:Alice
 * Date:15/9/2
 * Time:下午1:39
 * Version 1.0
 */
public class RenovationCase extends BaseDataHeader implements Serializable {
    private static final long serialVersionUID = 7673152158268348593L;
    //图片
    public String icon;
    //名字
    public String name;
    //好评
    public String fav;
    //描述
    public String des;
    //多少钱一平米
    public String price;
    //数据 id
    public String id;
    //大小
    public String size;
    //房型风格
    public String style;
    //设计师信息
    public DesignerInfo designer;
    //公司信息
    public CompanyInfo company;

    public static RenovationCase deserialize(String json) throws JSONException {
        if (json != null && !json.isEmpty()) {
            return deserialize(new JSONObject(json));
        }
        return null;
    }

    public static RenovationCase deserialize(JSONObject json) throws JSONException {
        if (json != null && json != JSONObject.NULL && json.length() > 0) {
            RenovationCase result = new RenovationCase();

            if (!json.isNull("icon")) {
                result.icon = json.optString("icon", null);
            }

            if (!json.isNull("name")) {
                result.name = json.optString("name", null);
            }

            if (!json.isNull("fav")) {
                result.fav = json.optString("fav", null);
            }

            if (!json.isNull("des")) {
                result.des = json.optString("des", null);
            }

            if (!json.isNull("price")) {
                result.price = json.optString("price", null);
            }

            if (!json.isNull("id")) {
                result.id = json.optString("id", null);
            }

            if (!json.isNull("size")) {
                result.size = json.optString("size", null);
            }

            if (!json.isNull("style")) {
                result.price = json.optString("style", null);
            }

            if (!json.isNull("designer")) {
                result.designer = DesignerInfo.deserialize(json.optJSONObject("designer"));
            }

            if (!json.isNull("company")) {
                result.company = CompanyInfo.deserialize(json.optJSONObject("company"));
            }

            return result;
        }
        return null;
    }
}
